#ifndef _SHADER_MANAGER_H_
#define _SHADER_MANAGER_H_

#include "Renderer.h"

class ShaderManager
{
	//////////////////////////////////////////////////////////////////////////
	//	------------------------------------------------------------------	//
	//							DATA	MEMBERS								//
	//	------------------------------------------------------------------	//
	//////////////////////////////////////////////////////////////////////////

	// Singleton's static instance
	static ShaderManager* sm_pInstance;

	vector<ID3DXEffect*> m_vpShaders;

	//////////////////////////////////////////////////////////////////////////
	//	------------------------------------------------------------------	//
	//							PRIVATE	FUNCTIONS							//
	//	------------------------------------------------------------------	//
	//////////////////////////////////////////////////////////////////////////

	// Default Constructor - Initialize all variables to safe values
	ShaderManager(void);

	// For a proper singleton, the trilogy needs to be defined
	ShaderManager(const ShaderManager&) {}				// Copy Constructor
	ShaderManager& operator=(const ShaderManager&) {}	// Assignment Operator
	~ShaderManager(void) {}								// Destructor

public:
	//////////////////////////////////////////////////////////////////////////
	//	------------------------------------------------------------------	//
	//							PUBLIC	FUNCTIONS							//
	//	------------------------------------------------------------------	//
	//////////////////////////////////////////////////////////////////////////

	// Used to access the singleton's instance
	static ShaderManager* GetInstance(void);

	// Used to delete the singleton's instance
	static void DeleteInstance(void);

	void Initialize(void);

	int LoadShader(const char* filename);
	
	// Calls Begin on the specified shader
	// Returns the number of passes or -1 if failed
	UINT BeginShader(int shaderID);
	void EndShader(int shaderID);

	void BeginPass(int shaderID, UINT pass);
	void EndPass(int shaderID);

	void SetTechnique(int shaderID, const char* technique);

	void SetMatrix(int shaderID, D3DXHANDLE param, const D3DXMATRIX* matrix);
	void SetTexture(int shaderID, D3DXHANDLE param, IDirect3DTexture9* texture);
	void CommitChanges(int shaderID);

};

#define SHADER_MNG ShaderManager::GetInstance()

#endif // _SHADER_MANAGER_H_